package cn.elves.model.activity.controller;

import cn.elves.model.entity.dto.response.ResponseDTO;
import cn.elves.model.activity.entity.po.Activity;
import cn.elves.model.activity.service.ActivityService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController("drawing")
public class ActivityController {

    @Resource
    private ActivityService activityService;

    @GetMapping("/activity/page/{pageSize}/{pageNum}")
    public ResponseDTO<Page<Activity>> activityPage(@PathVariable("pageSize") Integer pageSize, @PathVariable("pageNum") Integer pageNum) {
        return ResponseDTO.success(activityService.page(new Page<>(pageSize, pageNum)));
    }

    @GetMapping("/activity/{id}")
    public ResponseDTO<Activity> selectActivity(@PathVariable("id") Long id) {
        return ResponseDTO.success(activityService.getById(id));
    }

    @PostMapping("/activity")
    public ResponseDTO<Activity> saveActivity(Activity activity) {
        activityService.save(activity);
        return ResponseDTO.success();
    }

    @PutMapping("/activity")
    public ResponseDTO<Activity> updateActivity(Activity activity) {
        activityService.updateById(activity);
        return ResponseDTO.success();
    }

    @PatchMapping("/activity/toArraignmentState/{activityId}")
    public ResponseDTO<Activity> toArraignmentState(@PathVariable("activityId") Long id) {
        activityService.toArraignmentState(id);
        return ResponseDTO.success();
    }

    @PatchMapping("/activity/toPassState/{activityId}")
    public ResponseDTO<Activity> toPassState(@PathVariable("activityId") Long id) {
        activityService.toPassState(id);
        return ResponseDTO.success();
    }

    @PatchMapping("/activity/toRefuseState/{activityId}")
    public ResponseDTO<Activity> toRefuseState(@PathVariable("activityId") Long id) {
        activityService.toRefuseState(id);
        return ResponseDTO.success();
    }

    @PatchMapping("/activity/toRevokeState/{activityId}")
    public ResponseDTO<Activity> toRevokeState(@PathVariable("activityId") Long id) {
        activityService.toRevokeState(id);
        return ResponseDTO.success();
    }

    @PatchMapping("/activity/toCloseState/{activityId}")
    public ResponseDTO<Activity> toCloseState(@PathVariable("activityId") Long id) {
        activityService.toCloseState(id);
        return ResponseDTO.success();
    }

    @PatchMapping("/activity/toOpenState/{activityId}")
    public ResponseDTO<Activity> toOpenState(@PathVariable("activityId") Long id) {
        activityService.toOpenState(id);
        return ResponseDTO.success();
    }

    @PatchMapping("/activity/toDoingState/{activityId}")
    public ResponseDTO<Activity> toDoingState(@PathVariable("activityId") Long id) {
        activityService.toDoingState(id);
        return ResponseDTO.success();
    }


}
